# -*- coding: utf-8 -*-
# @Time    : 2021/6/28 10:26
# @Author  : zcn
# @Software: PyCharm

import os

from fastapi import APIRouter
from re_common.baselibrary.utils.basedir import BaseDir

from apps.core.m_route import ContextIncludedRoute
from apps.core.return_info import ReturnInfo, SUCCESS

router = APIRouter(route_class=ContextIncludedRoute)

@router.get("/git_ctrl/pull")
async def get_server_except():
    '''
    针对服务器进行git_pull
    :return:
    '''
    return_info = ReturnInfo()
    cur_path = BaseDir.get_file_dir_absolute(__file__)
    top_path = BaseDir.get_upper_dir(cur_path, -3)
    adb = f"cd {top_path} & git pull"
    data = os.system(adb)
    return_info.status = SUCCESS
    return_info.msg_code = 200
    return_info.msg = "更新完成"
    return_info.data = data
    return return_info.todict()
